1 using UnityEngine;
2 using
System.Collections;
3
4 public
class Node : Scalable, IHeapItem<Node>, IClickable {
5     
public int row;
6     
public int col;
7
8     
public char rowChess;
9     
public char colChess;
10
11     
//public bool walkable = true;
12     
13     
public int gCost;
14     
public int hCost;
15     
16     
private int heapIndex;
17
18     
private Piece piece;
19
20     
protected override void Start() {
21         
base.Start();
22     }
23
24     
public string ChessCoords {
25         
get {return "" + colChess + rowChess;}
26     }
27
28     
public Piece Piece {
29         
get {return piece;}
30         
set {
31             piece =
value;
32         }
33     }
34
35     
public void HighlightMove() {
36         
if (renderer.sharedMaterial != origMaterial) return;
37         SetMaterial(GameManager.Instance.HighlightMoveMaterial);
38     }
39
40     
public void HighlightEat() {
41         
if (renderer.sharedMaterial != origMaterial) return;
42         SetMaterial(GameManager.Instance.HighlightEatMaterial);
43     }
44
45     
public void HighlightCheck() {
46         
if (renderer.sharedMaterial != origMaterial) return;
47         SetMaterial(GameManager.Instance.HighlightCheckMaterial);
48     }
49
50     
public void UnhighlightMove() {
51         Unhiglight(GameManager.Instance.HighlightMoveMaterial);
52     }
53     
54     
public void UnhighlightEat() {
55         Unhiglight(GameManager.Instance.HighlightEatMaterial);
56     }
57
58     
public void UnhighlightCheck() {
59         Unhiglight(GameManager.Instance.HighlightCheckMaterial);
60     }
61
62     
private void Unhiglight(Material material) {
63         
if (renderer.sharedMaterial == material) {
64             SetMaterialOriginal();
65         }
66     }
67
68     
public bool EmptySpace {
69         
get {
70             
return piece == null;
71         }
72     }
73
74     
public void Clear() {
75         piece =
null;
76     }
77
78     
public int fCost {
79         
get {
80             
return gCost + hCost;
81         }
82     }
83
84     
public int HeapIndex {
85         
get {
86             
return heapIndex;
87         }
88         
set {
89             heapIndex =
value;
90         }
91     }
92
93     
public bool Inform<T>(T arg) {
94         
//TODO
95         
return true;
96     }
97
98     
public int CompareTo(Node nodeToCompare) {
99         
int compare = fCost.CompareTo(nodeToCompare.fCost);
100         
if (compare == 0) {
101             compare = hCost.CompareTo(nodeToCompare.hCost);
102         }
103
104         
return compare;
105     }
106
107     
public override string ToString() {
108         
return "" + row + "x" + col;
109     }
110 }


public bool walkable = true;

TODO



Gõ tìm kiếm nhanh...